home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / vidhandl / video.src < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-03  |  45.9 KB  |  2,123 lines

  1. //* * * Archive created by MONTA utility * * * 
  2.  
  3. //<FILE="printsf.h">
  4. extern int vsprintf(char *__buffer, const char *__format, void *__arglist);
  5.  
  6. #define __size(x) ((sizeof(x)+sizeof(int)-1) & ~(sizeof(int)-1))
  7.  
  8. #define va_start(ap, parmN) ((void)((ap) = (void *)((char *)(&parmN)+__size(parmN))))
  9.  
  10. #define va_arg(ap, type) (*(type *)(((*(char **)&(ap))+=__size(type))-(__size(type))))
  11. #define va_end(ap)          ((void)0)
  12. //</FILE>
  13.  
  14. //<FILE="crtwin.h">
  15. struct crtwin //structure type of crtwin_dta global variable
  16.  {
  17.     int left;
  18.     int top;
  19.     int right;
  20.     int bottom;
  21.  };
  22.  
  23. extern struct crtwin crtwin_dta;
  24.  
  25. #define xi crtwin_dta.left
  26. #define xf crtwin_dta.right
  27. #define yi crtwin_dta.top
  28. #define yf crtwin_dta.bottom
  29. //</FILE>
  30.  
  31. //<FILE="crtvar.c">
  32. //Declaration and initialization of CRT.H functions global variables.
  33. //The comments about them refers to expected or default values, not to actual
  34. //values. If actual values are different of default values, the user might
  35. //want to load in these variables the actual values (using some special
  36. //functions or changing their values) in order to CRT.H functions work
  37. //properly
  38.  
  39. int vmode_x=80;    //number of expected columns in text mode (default=80)*
  40. int vmode_y=25;      //number of expected rows in text mode (default=25)*
  41. int vmode_mode=3; //expected video mode (default=3) (updated by CRT.H functions)
  42.                         //* by CRT.H functions
  43.                         //They might be sometimes different from the actual number
  44.                         //of rows and columns in current text mode. To load their
  45.                         //actual values use crt_detect. crt_init also updates
  46.                         //crtwin_dta coordinates to full screen.
  47.  
  48. int  crt_direct=0;// if == 0 CRT.H functions write/read directly to video RAM,
  49.     //otherwise, they write/read by BIOS calls (INT 10h)
  50. int  crt_page=0;  //text page used when crt_direct!=0
  51.  
  52. int  crt_EVGA_addr=0x3C0; //EGA/VGA base port address. Alternate at 0x2C0
  53.  
  54. char far *video_addr=(char far*)0xb8000000UL;
  55.                             //base address for the video map (RAM)
  56.  
  57. char far *crtvar_p;    //pointer used in many functions to access the video RAM
  58.  
  59. struct crtwin            //coordinates used by crtwindow and printsj
  60.  {
  61.     int left;
  62.     int top;
  63.     int right;
  64.     int bottom;
  65.  }crtwin_dta={(int)-1,(int)-1,(int)80,(int)25}; //default values. This line means:
  66.     //crtwin_dta.left=-1;
  67.     //crtwin_dta.top=-1;
  68.     //crtwin_dta.right=80;
  69.     //crtwin_dta.bottom=25;
  70.  
  71. int crtwin_just=1; //used by printsj and printsjc. Default=1(CENTER TEXT)
  72. //</FILE>
  73.  
  74. //<FILE="crtdtect.c">
  75. unsigned char  __inportb__( int __portid );
  76. unsigned int   __inportw__( int __portid );
  77. void           __outportb__( int __portid, unsigned char __value );
  78. void           __outportw__( int __portid, unsigned int __value );
  79.  
  80. #define inportb         __inportb__
  81. #define outportb        __outportb__
  82.  
  83. #define MK_FP( seg,ofs )( (void _seg * )( seg ) +( void near * )( ofs ))
  84.  
  85. #define word unsigned int
  86. #define byte unsigned char
  87.  
  88. extern int vmode_x;
  89. extern int vmode_y;
  90. extern int vmode_mode;
  91. extern int crt_direct;
  92. extern int crt_page;
  93. extern int crt_EVGA_addr; //EGA/VGA base port address.
  94. extern char far *video_addr;
  95.  
  96. void crt_detect(int mode)
  97. //mode values:
  98.     //1 - CGA
  99.     //2 - MCGA
  100.     //3,4,5 - EGA
  101.     //9 - VGA,SVGA or better
  102.  {
  103.     register word a0;
  104.     register word a1;
  105.   //detects number of columns
  106.     vmode_x=*(word far *)0x40004AUL;
  107.   //detects current video mode
  108.     vmode_mode=*(byte far *)0x400049UL;
  109.   //detects current video page
  110.     crt_page=*(byte far *)0x400062UL;
  111.  
  112.     if ((mode>=2 && mode<=5)||mode==9) //if video is MCGA, EGA, VGA, or better
  113.      {
  114.         vmode_y=(*(byte far *)0x400084UL)+1; //detects vmode_y
  115.         if (mode!=2) //if video is not MCGA.
  116.          {
  117.             //detects if video is in text mode or graphics mode
  118.             inportb(crt_EVGA_addr-6u);
  119.             inportb(crt_EVGA_addr+0x1Au); //sets video's internal flipflop to r/w ATC index register
  120.             a0=inportb(crt_EVGA_addr+1u);
  121.             a0&=0xc0;
  122.             a0|=0x10;
  123.             outportb(crt_EVGA_addr,a0); //writes ATC index register and set's video's internal
  124.                                 //flipflop to r/w ATC data register
  125.             a0=inportb(crt_EVGA_addr+1u); //reads video status register
  126.             //a0 = EGA/VGA ATC mode control register
  127.  
  128.             inportb(crt_EVGA_addr-6u);
  129.             inportb(crt_EVGA_addr+0x1Au); //sets video's internal flipflop to r/w ATC index register
  130.             a1=inportb(crt_EVGA_addr+1u);
  131.             a1&=0xe0;
  132.             a1|=0x20;
  133.             outportb(crt_EVGA_addr,a1); //writes ATC index register and set's video's internal
  134.  
  135.             //Bitfields for EGA/VGA ATC mode control register:
  136.             //Bit(s)    Description    (Table P269)
  137.             // 7    (VGA) SB/SG select (0=4 pages of 64 regs, 1=16 pages of 16 regs)
  138.             // 6    (VGA) PELCLK/2 (0=4bit color, 1=8bit color)
  139.             // 5    (VGA) enable pixel panning (0=all, 1=up to line compare register value)
  140.             // 4    reserved
  141.             // 3    background intensity (0=16 colors, 1=blink)
  142.             // 2    line graphics enable (0=background, 1=line 8=9)
  143.             // 1    1=mono, 0=color select
  144.             // 0    1=graphics, 0=text select
  145.             //extracted from Ralf Brown's Interrupt List (file PORTS.LST)
  146.             crt_direct=a0%2;
  147.          }
  148.          else
  149.             goto jmp1;
  150.      }
  151.      else //if video is not MCGA, EGA, VGA or better
  152.      {
  153.         vmode_y=25;
  154.       jmp1: //if video is not EGA, VGA or better
  155.         crt_direct=((*(byte far *)0x400065UL)&0x02)/2u;
  156.      }
  157.  
  158.     //detects text buffer base address if video is in text mode
  159.     if (!crt_direct)
  160.      {
  161.  
  162.         if (vmode_mode!=7)
  163.             a0=0xb800;
  164.          else
  165.             a0=0xb000;
  166.         a1=*(word far*)0x40004EUL; //a1=current page start address in regen buffer
  167.         video_addr=(char far*)MK_FP(a0+a1/16,a1%16);
  168.      }
  169.  }
  170. //</FILE>
  171.  
  172. //<FILE="crt_init.c">
  173. extern int vmode_x;
  174. extern int vmode_y;
  175. extern int crtwin_just;
  176.  
  177. #include "crtwin.h"
  178.  
  179. extern void crt_detect(int mode);
  180.  
  181. void crt_init(int mode)
  182.  {
  183.     crt_detect(mode);
  184.     xi=-1;
  185.     yi=-1;
  186.     xf=vmode_x;
  187.     yf=vmode_y;
  188.     crtwin_just=1; //CENTER_TEXT
  189.  }
  190. //</FILE>
  191.  
  192. //<FILE="vmode.c">
  193. extern int vmode_x;    //number of columns in text mode (default=80)
  194. extern int vmode_y;  //number of rows in text mode (default=25)
  195. int vmode_lm=3;        //last mode used or selected by videomode (default=25x80)
  196. int vmode_am=3;    //current mode used by videomode (default=25x80)
  197.  
  198. void videomode (int newmode) //tells the functions declared in CRT.H which is
  199. //the "selected" mode number of rows and columns.
  200.  {
  201.     if (newmode==-1)
  202.         newmode=vmode_lm;
  203.     vmode_lm=vmode_am;
  204.     vmode_am=newmode;
  205.     switch (vmode_am)
  206.      {
  207.         case 0:    //executes the immediately following line
  208.         case 1: vmode_y=25; vmode_x=40; break; //25 x 40
  209.         case 2:
  210.         case 3:
  211.         case 7: vmode_y=25; vmode_x=80; break; //25 x 80
  212.         case 24:vmode_y=43; vmode_x=40; break; //43 x 40 (ega)
  213.         case 32:vmode_y=43; vmode_x=80; break; //43 x 80 (ega)
  214.         case 48:vmode_y=50; vmode_x=40; break; //50 x 40 (vga)
  215.         case 64:vmode_y=50; vmode_x=80; break; //50 x 80 (vga)
  216.      }
  217.  }
  218. //</FILE>
  219.  
  220. //<FILE="crtmode.c">
  221. #define intm(intnum) asm int intnum
  222. extern int vmode_x;
  223. extern int vmode_mode;
  224. extern int crt_page;
  225.  
  226. int getcrtmode (void) //returns the current video mode and updates
  227. //vmode_x and crt_page to current values.
  228. //vmode_y is not updated to actual value.
  229.  {
  230.     int a0;
  231.     asm push ax;
  232.     asm push bx;
  233.     _AH=0x0F;
  234.     intm(0x10);
  235.     asm mov bl,ah;
  236.     a0=_AL;
  237.     vmode_x=_BL;
  238.     crt_page=_BH;
  239.     vmode_mode=a0;
  240.     asm pop bx;
  241.     asm pop ax;
  242.     return a0;
  243.  }
  244.  
  245. void setcrtmode (int mode) //changes video mode and calls getcrtmode
  246.  {
  247.     asm push ax;
  248.     asm xor ax,ax; //ax=0;
  249.     _AL=mode;
  250.     asm int 0x10;
  251.     asm pop ax;
  252.     getcrtmode();
  253.  }
  254. //</FILE>
  255.  
  256. //<FILE="crtpage.c">
  257. extern int vmode_mode;
  258. extern char far *video_addr;
  259.  
  260. extern int getcrtmode (void);
  261.  
  262. #define MK_FP( seg,ofs )( (void _seg * )( seg ) +( void near * )( ofs ))
  263.  
  264. #define word unsigned int
  265.  
  266. void setcrtpage (int page) //selects active display page
  267. //the actual selected page number is stored in crt_page after a call to this
  268. //function
  269.  {
  270.     register word a0,a1;
  271.   //changes active display page
  272.     asm push ax;
  273.     _AL=page;
  274.     _AH=0x05;
  275.     asm int 0x10;
  276.     asm pop ax;
  277.  //updates vmode_mode and crt_page
  278.     getcrtmode ();
  279.  //updates video_addr;
  280.     if (vmode_mode!=7)
  281.         a0=0xb800;
  282.      else
  283.         a0=0xb000;
  284.     a1=*(word far*)0x40004EUL; //a1=current page start address in regen buffer
  285.     video_addr=(char far*)MK_FP(a0+a1/16,a1%16);
  286.  }
  287. //</FILE>
  288.  
  289. //<FILE="crt_gtxy.c">
  290. extern int crt_page;
  291.  
  292. void crt_gotoxy (int x, int y) //changes cursor position in text page defined
  293. //by crt_page.
  294.  {
  295.     asm push ax;
  296.     asm push bx;
  297.     asm push dx;
  298.     _BH=crt_page;
  299.     _DH=y;
  300.     _DL=x;
  301.     _AH=0x02;
  302.     asm int 0x10;
  303.     asm pop dx;
  304.     asm pop bx;
  305.     asm pop ax;
  306.  }
  307.  
  308. //</FILE>
  309.  
  310. //<FILE="getxy.c">
  311. extern int crt_page;
  312.  
  313. int crt_getxy (int *x, int *y) //gets current cursor position in text page
  314. //defined by crt_page.
  315.  {
  316.     int rtn;
  317.     asm push ax;
  318.     asm push bx;
  319.     asm push cx;
  320.     asm push dx;
  321.     _BH=crt_page;
  322.     _AH=0x03;
  323.     asm int 0x10;
  324.     rtn=_DX;
  325.     *y=_DH;
  326.     *x=_DL;
  327.     asm pop dx;
  328.     asm pop cx;
  329.     asm pop bx;
  330.     asm pop ax;
  331.     return rtn;
  332.  }
  333. //</FILE>
  334.  
  335. //<FILE="getcrtch.c">
  336. extern int vmode_x;
  337. extern int crt_direct;
  338. extern int crt_page;
  339. extern char far *video_addr;
  340.  
  341. extern void crt_gotoxy (int x, int y);
  342. extern int crt_getxy (int *x, int *y);
  343.  
  344. int getcrtchar (int x, int y)
  345.     //gets the character from position (x,y)
  346.  {
  347.     int xo,yo;
  348.     char far *crtvar_p;
  349.     unsigned int z;
  350.  
  351.     if (!crt_direct)
  352.      {
  353.         crtvar_p=video_addr + 2 * (x + y*vmode_x);
  354.         return *crtvar_p;
  355.      }
  356.  
  357.     crt_getxy (&xo,&yo);
  358.     crt_gotoxy (x,y);
  359.     asm push ax;
  360.     asm push bx;
  361.     _BH=crt_page;
  362.     _AH=0x08;
  363.     asm push bp;
  364.     asm int 0x10;
  365.     asm pop bp;
  366.     z=_AX;
  367.     asm pop bx;
  368.     asm pop ax;
  369.     crt_gotoxy(xo,yo);
  370.     return (z%0x100);
  371.  }
  372. //</FILE>
  373.  
  374. //<FILE="getcrtco.c">
  375. extern int vmode_x;
  376. extern int vmode_y;
  377. extern int crt_direct;
  378. extern int crt_page;
  379. extern char far *video_addr;
  380.  
  381. extern void crt_gotoxy (int x, int y);
  382. extern int crt_getxy (int *x, int *y);
  383.  
  384. int getcrtcolor (int x,int y)
  385.     //gets the color from position (x,y)
  386.  {
  387.     int xo,yo;
  388.     unsigned int z;
  389.     char far *crtvar_p;
  390.  
  391.     if (!crt_direct)
  392.      {
  393.         crtvar_p=video_addr + 1 + 2 * (x + y*vmode_x);
  394.         return *crtvar_p;
  395.      }
  396.  
  397.     crt_getxy (&xo,&yo);
  398.     crt_gotoxy (x,y);
  399.     asm push ax;
  400.     asm push bx;
  401.     _BH=crt_page;
  402.     _AH=0x08;
  403.     asm push bp;
  404.     asm int 0x10;
  405.     asm pop bp;
  406.     z=_AX;
  407.     asm pop bx;
  408.     asm pop ax;
  409.     crt_gotoxy(xo,yo);
  410.     return (z/0x100);
  411.  }
  412. //</FILE>
  413.  
  414. //<FILE="b_printc.c">
  415. extern int crt_page;
  416.  
  417. extern void crt_gotoxy (int x, int y);
  418. extern int crt_getxy (int *x, int *y);
  419.  
  420. void biosprintc (int chr, int x, int y, int color, int func)
  421. //prints a character at position (x,y) with color "color" if func=09h.
  422. //if func=0Ah prints character with no color.
  423.  {
  424.     int xo, yo;
  425.     crt_getxy(&xo,&yo);
  426.     crt_gotoxy (x,y);
  427.     asm push ax;
  428.     asm push bx;
  429.     asm push cx;
  430.     asm push dx;
  431.     _DH=func;
  432.     _DL=chr;
  433.     _BH=crt_page;
  434.     _BL=color;
  435.     _CX=0x01;
  436.     asm mov ax,dx;
  437.     asm int 0x10;
  438.     asm pop dx;
  439.     asm pop cx;
  440.     asm pop bx;
  441.     asm pop ax;
  442.     crt_gotoxy (xo,yo);
  443.  }
  444. //</FILE>
  445.  
  446. //<FILE="printcn.c">
  447. extern int vmode_x;
  448. extern int vmode_y;
  449. extern int crt_direct;
  450. extern char far *video_addr;
  451. extern char far *crtvar_p;
  452.  
  453. extern void biosprintc (int chr, int x, int y, int color, int func);
  454.  
  455. void printcn(int c,int x, int y)
  456.   //prints a character at position (x,y) keeping the old position color.
  457.  {
  458.     if ((unsigned)x>=(unsigned)vmode_x || (unsigned)y>=(unsigned)vmode_y)
  459.         return;
  460.     if (!crt_direct)
  461.      {
  462.         crtvar_p=video_addr + 2 * (x + y*vmode_x);
  463.         *crtvar_p=(char)c;
  464.         return;
  465.      }
  466.     biosprintc (c,x,y,0x07,0x0a);
  467.  }
  468. //</FILE>
  469.  
  470. //<FILE="printc.c">
  471.  
  472. extern int vmode_x;
  473. extern int vmode_y;
  474. extern int crt_direct;
  475.  
  476. extern char far *video_addr;
  477. extern char far *crtvar_p;
  478.  
  479. extern void biosprintc (int chr, int x, int y, int color, int func);
  480.  
  481. void printc(int c, int x, int y, int color)
  482.  //prints the character "c" with color "color" at position (x,y).
  483.  {
  484.     if ((unsigned)x>=(unsigned)vmode_x || (unsigned)y>=(unsigned)vmode_y)
  485.         return;
  486.     if (!crt_direct)
  487.      {
  488.         crtvar_p=video_addr + 2 * (x + y*vmode_x);
  489.         *crtvar_p=(char)c;
  490.         crtvar_p++;
  491.         *crtvar_p=(char)color;
  492.         return;
  493.      }
  494.     biosprintc (c,x,y,color,0x09);
  495.  }
  496. //</FILE>
  497.  
  498. //<FILE="changeco.c">
  499. extern int vmode_x;
  500. extern int vmode_y;
  501. extern int crt_direct;
  502.  
  503. extern char far *video_addr;
  504.  
  505. extern int getcrtchar (int x, int y);
  506. extern void printc(int c, int x, int y, int color);
  507.  
  508. void changecolor(int x, int y, int color)
  509.   //changes the color at position (x,y) replacing the old color by "color"
  510.  {
  511.     int chr;
  512.     char far *crtvar_p;
  513.     if ((unsigned)x>=(unsigned)vmode_x || (unsigned)y>=(unsigned)vmode_y)
  514.         return;
  515.  
  516.     if (!crt_direct)
  517.      {
  518.         crtvar_p=video_addr+1 + 2 * (x + y*vmode_x);
  519.         *crtvar_p=(char)color;
  520.         return;
  521.      }
  522.     chr=getcrtchar(x,y);
  523.     printc(chr,x,y,color);
  524.  }
  525. //</FILE>
  526.  
  527. //<FILE="printct.c">
  528. extern int vmode_x;
  529. extern int vmode_y;
  530. extern int crt_direct;
  531.  
  532. extern char far *video_addr;
  533. extern char far *crtvar_p;
  534.  
  535. extern int getcrtchar (int x, int y);
  536. extern void biosprintc (int chr, int x, int y, int color, int func);
  537.  
  538. void printct(int c, int x, int y, int color, unsigned int type)
  539.     //replaces the character and/or color of position (x,y) according
  540.     //to type parameter.
  541.  {
  542.     if ((unsigned)x>=(unsigned)vmode_x || (unsigned)y>=(unsigned)vmode_y)
  543.         return;
  544.     if (!crt_direct)
  545.      {
  546.         crtvar_p=video_addr + 2 * (x + y*vmode_x);
  547.         if (type & 0x01)
  548.             *crtvar_p=(char)c;
  549.         crtvar_p++;
  550.         if (type & 0x02)
  551.             *crtvar_p=(char)color;
  552.         return;
  553.      }
  554.     if (!(type & 0x01))
  555.         c=getcrtchar(x,y);
  556.     if (!(type & 0x02))
  557.         color=0x07;
  558.     biosprintc (c,x,y,color,0x0A-(type & 0x02)/2U);
  559.  }
  560. //</FILE>
  561.  
  562. //<FILE="printsn.c">
  563. extern void printcn(int c, int x, int y);
  564.  
  565. void printsn(char *s, int x, int y)
  566.   //prints a string starting from postion (x,y), keeping the old colors of
  567.   //positions where the string is going to be printed.
  568.  {
  569.     while (*s)
  570.      {
  571.         printcn((int)*s,x,y);
  572.         x++;
  573.         s++;
  574.      }
  575.  }
  576. //</FILE>
  577.  
  578. //<FILE="prints.c">
  579. extern void printc(int c, int x, int y, int color);
  580.  
  581. void prints(char *s, int x, int y, int color)
  582.  //prints a string at position (x,y) with color "color".
  583.  {
  584.     while (*s)
  585.      {
  586.         printc((int)*s,x,y,color);
  587.         x++;
  588.         s++;
  589.      }
  590.  }
  591. //</FILE>
  592.  
  593. //<FILE="printxy.c">
  594. extern void    printc (int c, int x, int y, int color);
  595.  
  596. void printxy (char *s, int x, int y, int dx, int dy, int color)
  597.  //prints a string at position (x,y) with character spacing (dx,dy) with color
  598.  {
  599.     while (*s)
  600.      {
  601.         printc ((int)*s,x,y,color);
  602.         x+=dx;
  603.         y+=dy;
  604.         s++;
  605.      }
  606.  }
  607. //</FILE>
  608.  
  609. //<FILE="printx.c">
  610. extern int vmode_x;
  611.  
  612. extern void printc(int c, int x, int y, int color);
  613.  
  614. void printx (char *s, int x, int y, int color)
  615. //prints a string with special formats.
  616. //eg. \n \t color change, position change, pause, beep, special character,
  617. //and other features.
  618. //Note: This function doesn't changes cursor position.
  619.  {
  620.     int flag,color2;
  621.     int tabsizep=8; //default tab size
  622.     int taboffst=0; //taboffset from left border
  623.     flag=0;
  624.     while (*s)
  625.      {
  626.         if (*s>0x1b || *s<0x05)
  627.             goto jp1;
  628.         switch (*s) //verifies if it is a control byte (or character)
  629.          {
  630.             case 0x05: //prints a character with the previous defined color
  631.                 color2=color; //format => 05h;color;char;
  632.                 s++;              //prints any character, even if it is a format char.
  633.                 color=*s;
  634.                 flag=1;
  635.                 s++;
  636.              goto jp1;
  637.             case 0x06: //changes current color    format => 06h;color
  638.                 s++;
  639.                 color=*s;
  640.              break;
  641.             case 0x07: //sends a beep using a DOS call (INT 21h)
  642.                 asm {
  643.                     push ax
  644.                     push dx
  645.                     mov dl,0x07
  646.                     mov ah,0x02
  647.                     int 0x21
  648.                     pop dx
  649.                     pop ax
  650.                  }            //format => 07h;
  651.              break;
  652.             case 0x08: //bkspace
  653.                 x--;
  654.              break;
  655.             case 0x09: //tab
  656.                 x=x-taboffst;
  657.                 x=x-(x%tabsizep)+tabsizep+taboffst;
  658.              break;
  659.             case 0x0a: //line feed and carriage return until column=taboffset
  660.                 y++;
  661.                 x=taboffst;
  662.              break;
  663.             case 0x0b: //line feed
  664.                 y++;
  665.              break;
  666.             case 0x0c: //goes to upper left corner
  667.                 y=0;
  668.                 x=0;
  669.              break;
  670.             case 0x0d: //carriage return
  671.                 x=taboffst;
  672.              break;
  673.             case 0x0e: //changes "x" value, which determines current column
  674.                 s++;
  675.                 x=*s;
  676.              break;
  677.             case 0x0f: //changes "y" value, which determines current row
  678.                 s++;
  679.                 y=*s;
  680.              break;
  681.             case 0x10: //changes tab size
  682.                 s++;
  683.                 tabsizep=*s;
  684.              break;
  685.             case 0x11: //changes taboffset
  686.                 s++;
  687.                 taboffst=*s;
  688.              break;
  689.             case 0x12: //increments x;
  690.                 x++;
  691.              break;
  692.             case 0x13: //decrements y;
  693.                 y--;
  694.              break;
  695.             case 0x14: //pauses until a keyboard character is available (reads a
  696.                           //single character which is ignored). Checks CTRL-BREAK
  697.                 asm push ax
  698.                 _AH=0x08;
  699.                 asm int 0x21;
  700.                 asm pop ax;
  701.              break;
  702.             case 0x15: //pauses until a keyboard character is available,
  703.                           //but doesn't check CRTL-BREAK.
  704.                 asm push ax;
  705.                 _AH=0x07;
  706.                 asm int 0x21;
  707.                 asm pop ax;
  708.              break;
  709.             case 0x1b: //prints any ascii character, even if it is a format byte
  710.                 s++;
  711.             default: //if it isn't any format character, prints character at
  712.                         //screen
  713.               jp1:
  714.                 while (x>=vmode_x)    //protection
  715.                  {
  716.                     x=x-vmode_x;
  717.                     y++;
  718.                  }
  719.                 while (x<0)                //protection
  720.                  {
  721.                     x=x+vmode_x;
  722.                     y--;
  723.                  }
  724.                 printc(*s,x,y,color);//character output at screen
  725.                 x++;
  726.                 if (flag)
  727.                  {
  728.                     color=color2;
  729.                     flag=0;
  730.                  }
  731.          }
  732.         s++;
  733.      }
  734.  }
  735. //</FILE>
  736.  
  737. //<FILE="printt.c">
  738. #include "crtwin.h"
  739.  
  740. extern void printc(int c, int x, int y, int color);
  741.  
  742. int printtext (char *s, int x, int y, int color)
  743. //prints a string inside a text window defined by crtwin_dta, continuing into
  744. //the next line if necessary
  745.  {
  746.     unsigned cnt=0;
  747.     unsigned c0, c1;
  748.     if (x<0 || y<0)
  749.         return 0;
  750.     c1=xi+x+1;
  751.     for (c0=yi+1+y;(unsigned)c0<(unsigned)yf;c0++)
  752.      {
  753.         while (c1<(unsigned)xf)
  754.          {
  755.             if (!(*s))
  756.                 return cnt;
  757.             cnt++;
  758.             printc(*s,c1,c0,color);
  759.             s++;
  760.             c1++;
  761.          }
  762.         c1=xi+1;
  763.      }
  764.     return cnt;
  765.  }
  766. //</FILE>
  767.  
  768. //<FILE="printsj.c">
  769. #include "crtwin.h"
  770.  
  771. extern int crtwin_just; //default=1 (CENTER TEXT)
  772.  
  773. extern void        printc    (int c, int x, int y, int color);
  774. extern unsigned int strlen(const char *__s);
  775.  
  776. int  __abs__(int);
  777.  
  778. void printsj (char *s, int y, int color)
  779. //Writes a string inside the box defined by crtwin_dta struct with justification
  780. //defined by crtwin_just.
  781.  {
  782.     int a0,a1; //auxiliar variables
  783.  
  784.     if ((yi+1)>=yf) //protection
  785.         return;
  786.  
  787.  //determines the row where the text will be written
  788.     y=(unsigned)y%(yf-yi-1)+yi+1;
  789.  
  790.  //determines the position where the text will be written on screen
  791.  //according to crtwin_dta and crtwin_just and its size
  792.     a0=strlen(s);
  793.     switch (crtwin_just)
  794.      {
  795.         case 0: a1=xi+1; break;
  796.         case 1: a1=(xi+xf-a0+1)/2; break;
  797.         case 2: a1=xf-a0; break;
  798.         default: return;
  799.      }
  800.  
  801. //writes the text
  802.     while(*s)
  803.      {
  804.         if ((a1>xi)&&(a1<xf)) //is char inside the box defined by crtwin_dta?
  805.             printc(*s,a1,y,color); //if so, writes it.
  806.         a1++;
  807.         s++;
  808.      }
  809.  }
  810. //</FILE>
  811.  
  812. //<FILE="printsjc.c">
  813. #include "crtwin.h"
  814.  
  815. extern int crtwin_just; //default=1 (CENTER TEXT)
  816.  
  817. extern void    printc (int c, int x, int y, int color);
  818.  
  819. int printsjc_textlen (char *s)
  820. //returns the size of the text excluding color "instruction" bytes.
  821.  {
  822.     int c0=0; //counts the number of chars to be written
  823.     while (*s)
  824.      {
  825.         if (*s==6 || *s==5 || *s==0x1b)
  826.          {
  827.             if (*s==0x1b)
  828.                 c0++;
  829.             s++;
  830.          }
  831.          else
  832.             c0++;
  833.         s++;
  834.      }
  835.     return c0;
  836.  }
  837.  
  838. void printsjc (char *s, int y, int color)
  839. //Writes a string inside the box defined by crtwin_dta struct with justification
  840. //defined by crtwin_just. Allows the user to change the color in the middle
  841. //of the string, inserting special characters inside the string
  842.  {
  843.     int a0,a1; //auxiliar variables
  844.     int color2; //stores the old color
  845.     int rstcolor=0; //if ==1 restores old color
  846.  
  847.     if ((yi+1)>=yf) //protection
  848.         return;
  849.  
  850.  //determines the row where the text will be written
  851.     y=(unsigned)y%(yf-yi-1)+yi+1;
  852.  
  853.  //determines the position where the text will be written on screen
  854.  //according to crtwin_dta and crtwin_just
  855.     a0=printsjc_textlen(s);
  856.     switch (crtwin_just)
  857.      {
  858.         case 0: a1=xi+1; break;
  859.         case 1: a1=(xi+xf-a0+1)/2; break;
  860.         case 2: a1=xf-a0; break;
  861.         default: return;
  862.      }
  863.  
  864. //writes the text
  865.     while(*s)
  866.      {
  867.         if (*s==5)
  868.          {
  869.             if (!rstcolor)
  870.              {
  871.                 color2=color;
  872.                 s++;
  873.                 color=*s;
  874.                 rstcolor++;
  875.              }
  876.             else
  877.                 s++;
  878.          }
  879.         else if (*s==6)
  880.          {
  881.             rstcolor=0;
  882.             s++;
  883.             color=*s;
  884.          }
  885.         else
  886.          {
  887.             if (*s==0x1b)
  888.                 s++;
  889.             if ((a1>xi)&&(a1<xf)) //is char inside the box defined by crtwin_dta?
  890.                 printc(*s,a1,y,color); //if so, writes it.
  891.             a1++;
  892.             if (rstcolor) //restores old color
  893.              {
  894.                 rstcolor=0;
  895.                 color=color2;
  896.              }
  897.          }
  898.         s++;
  899.      }
  900.  }
  901. //</FILE>
  902.  
  903. //<FILE="printsnf.c">
  904. extern void printsn(char *s, int x, int y);
  905. #include "printsf.h"
  906.  
  907. int printsnf(int x, int y, char *fmt,... )
  908. //sends formatted output using printsn function.
  909.  {
  910.     void *argptr;
  911.     char s[256];
  912.     int rtn;
  913.     va_start(argptr, fmt);
  914.     rtn = vsprintf(s, fmt, argptr);
  915.     printsn(s,x,y);
  916.     va_end(argptr);
  917.     return rtn;
  918.  }
  919. //</FILE>
  920.  
  921. //<FILE="printsf.c">
  922. extern void prints(char *s, int x, int y, int color);
  923. #include "printsf.h"
  924.  
  925. int printsf(int x, int y, int color, char *fmt,... )
  926. //sends formatted output using prints function.
  927.  {
  928.     void *argptr;
  929.     char s[256];
  930.     int rtn;
  931.     va_start(argptr, fmt );
  932.     rtn = vsprintf(s, fmt, argptr);
  933.     prints(s,x,y,color);
  934.     va_end(argptr);
  935.     return rtn;
  936.  }
  937. //</FILE>
  938.  
  939. //<FILE="printxyf.c">
  940. extern void printxy (char *s, int x, int y, int dx, int dy, int color);
  941. #include "printsf.h"
  942.  
  943. int printxyf (int x, int y, int dx, int dy, int color, char *fmt,... )
  944. //sends formatted output using printxy function.
  945.  {
  946.     void *argptr;
  947.     char s[256];
  948.     int rtn;
  949.     va_start(argptr, fmt );
  950.     rtn = vsprintf(s, fmt, argptr);
  951.     printxy(s,x,y,dx,dy,color);
  952.     va_end(argptr);
  953.     return rtn;
  954.  }
  955. //</FILE>
  956.  
  957. //<FILE="printxf.c">
  958. extern void printx (char *s, int x, int y, int color);
  959. #include "printsf.h"
  960.  
  961. int printxf(int x, int y, int color, char *fmt,... )
  962. //sends formatted output using printx function.
  963.  {
  964.     void *argptr;
  965.     char s[4096];
  966.     int rtn;
  967.     va_start(argptr, fmt );
  968.     rtn = vsprintf(s, fmt, argptr);
  969.     printx(s,x,y,color);
  970.     va_end(argptr);
  971.     return rtn;
  972.  }
  973. //</FILE>
  974.  
  975. //<FILE="printtf.c">
  976. extern int printtext (char *s, int x, int y, int color);
  977. #include "printsf.h"
  978.  
  979. int printtextf(int x, int y, int color, char *fmt,... )
  980. //sends formatted output using printtext function.
  981.  {
  982.     void *argptr;
  983.     char s[4096];
  984.     int rtn;
  985.     va_start(argptr, fmt );
  986.     rtn = vsprintf(s, fmt, argptr);
  987.     printtext(s,x,y,color);
  988.     va_end(argptr);
  989.     return rtn;
  990.  }
  991. //</FILE>
  992.  
  993. //<FILE="printsjf.c">
  994. extern void printsj (char *s, int y, int color);
  995. #include "printsf.h"
  996.  
  997. int printsjf(int y, int color, char *fmt,... )
  998. //sends formatted output using printsj function.
  999.  {
  1000.     void *argptr;
  1001.     char s[256];
  1002.     int rtn;
  1003.     va_start(argptr, fmt);
  1004.     rtn = vsprintf(s, fmt, argptr);
  1005.     printsj(s,y,color);
  1006.     va_end(argptr);
  1007.     return rtn;
  1008.  }
  1009. //</FILE>
  1010.  
  1011. //<FILE="prntsjcf.c">
  1012. extern void printsjc (char *s, int y, int color);
  1013. #include "printsf.h"
  1014.  
  1015. int printsjcf(int y, int color, char *fmt,... )
  1016. //sends formatted output using printsjc function.
  1017.  {
  1018.     void *argptr;
  1019.     char s[256];
  1020.     int rtn;
  1021.     va_start(argptr, fmt);
  1022.     rtn = vsprintf(s, fmt, argptr);
  1023.     printsjc (s,y,color);
  1024.     va_end(argptr);
  1025.     return rtn;
  1026.  }
  1027. //</FILE>
  1028.  
  1029. //<FILE="fillscr.c">
  1030. extern int vmode_x;
  1031. extern int vmode_y;
  1032. extern int crt_direct;
  1033. extern char far *video_addr;
  1034.  
  1035. extern void biosprintc (int chr, int x, int y, int color, int func);
  1036.  
  1037. void fillscr (int c, int color)
  1038.     //fills the screen with character "c" and color "color"
  1039.  {
  1040.     int c0,c1,a0;
  1041.     char far *crtvar_p;
  1042.     a0=vmode_x*vmode_y; //number of character positions in screen
  1043.     crtvar_p=video_addr;
  1044.     if (!crt_direct)
  1045.      {
  1046.         for (c0=0;c0<a0;c0++)
  1047.          {
  1048.             *crtvar_p=(char)c;
  1049.             crtvar_p++;
  1050.             *crtvar_p=(char)color;
  1051.             crtvar_p++;
  1052.          }
  1053.         return;
  1054.      }
  1055.     for (c0=0;c0<vmode_y;c0++)
  1056.         for (c1=0;c1<vmode_x;c1++)
  1057.             biosprintc (c,c1,c0,color,0x09);
  1058.  }
  1059. //</FILE>
  1060.  
  1061. //<FILE="barcolor.c">
  1062. extern int vmode_x;
  1063. extern int vmode_y;
  1064.  
  1065. extern void changecolor(int x, int y, int color);
  1066.  
  1067. void barcolor (int xi, int yi, int xf, int yf, int color)
  1068. //replaces the window color. The window corners are (xi,yi) and (xf,yf)
  1069.  {
  1070.     int x,y;
  1071.  
  1072.     //Avoids waste of time in unuseless calls to chagecolor
  1073.     if (yi<0)
  1074.         yi=0;
  1075.     if (xi<0)
  1076.         xi=0;
  1077.     if (yf>=vmode_y)
  1078.         yf=vmode_y-1;
  1079.     if (xf>=vmode_x)
  1080.         xf=vmode_x-1;
  1081.  
  1082.     //Replaces the window color.
  1083.     for (y=yi;y<(yf+1);y++) //y<(yf+1) => protection against infinite loop
  1084.         for (x=xi;x<(xf+1);x++) //when yf=7FFFh. The same for x and xf
  1085.             changecolor (x,y,color);
  1086.  
  1087.  }
  1088.  
  1089. //</FILE>
  1090.  
  1091. //<FILE="fillbar.c">
  1092. extern int vmode_x;
  1093. extern int vmode_y;
  1094.  
  1095. extern void printc(int c, int x, int y, int color);
  1096.  
  1097. void fillbar (int c, int xi, int yi, int xf, int yf, int color)
  1098.     //fills a text-window from (xi,yi) to (xf,yf) with character "c" and color
  1099.     //"color", where (xi,yi) is the upper left corner and (xf,yf) is the lower
  1100.     //right corner of the window.
  1101.  {
  1102.     int x,y;
  1103.  
  1104.     //Avoids waste of time in unuseless calls to chagecolor
  1105.     if (yi<0)
  1106.         yi=0;
  1107.     if (xi<0)
  1108.         xi=0;
  1109.     if (yf>=vmode_y)
  1110.         yf=vmode_y-1;
  1111.     if (xf>=vmode_x)
  1112.         xf=vmode_x-1;
  1113.  
  1114.     //Replaces the window color.
  1115.     for (y=yi;y<(yf+1);y++) //y<(yf+1) => protection against infinite loop
  1116.         for (x=xi;x<(xf+1);x++) //when yf=7FFFh. The same for x and xf
  1117.             printc (c,x,y,color);
  1118.  
  1119.  }
  1120. //</FILE>
  1121.  
  1122. //<FILE="fillbarw.c">
  1123. extern void fillbar (int c, int xi, int yi, int xf, int yf, int color);
  1124.  
  1125. #include "crtwin.h"
  1126.  
  1127. void fillbarw (int c, int color)
  1128.  {
  1129.     fillbar (c,xi+1,yi+1,xf-1,yf-1,color);
  1130.  }
  1131. //</FILE>
  1132.  
  1133. //<FILE="fillbox.c">
  1134. extern int vmode_x;
  1135. extern int vmode_y;
  1136.  
  1137. extern void printct(int c, int x, int y, int color, unsigned int type);
  1138.  
  1139. void fillbox (int c, int xi, int yi, int xf, int yf, int color, int func)
  1140.     //fills a text-window from (xi,yi) to (xf,yf) with character "c" and color
  1141.     //"color", where (xi,yi) is the upper left corner and (xf,yf) is the lower
  1142.     //right corner of the window.
  1143.  {
  1144.     int x,y;
  1145.     //Avoids waste of time in unuseless calls to chagecolor
  1146.     if (yi<0)
  1147.         yi=0;
  1148.     if (xi<0)
  1149.         xi=0;
  1150.     if (yf>=vmode_y)
  1151.         yf=vmode_y-1;
  1152.     if (xf>=vmode_x)
  1153.         xf=vmode_x-1;
  1154.  
  1155.     //Replaces the window color.
  1156.     for (y=yi;y<(yf+1);y++) //y<(yf+1) => protection against infinite loop
  1157.         for (x=xi;x<(xf+1);x++) //when yf=7FFFh. The same for x and xf
  1158.             printct (c,x,y,color,func);
  1159.  }
  1160. //</FILE>
  1161.  
  1162. //<FILE="fillboxw.c">
  1163. extern void fillbox (int c, int xi, int yi, int xf, int yf, int color, int func);
  1164.  
  1165. #include "crtwin.h"
  1166.  
  1167. void fillboxw (int c, int color, int func)
  1168.  {
  1169.     fillbox (c, xi+1, yi+1, xf-1, yf-1, color, func);
  1170.  }
  1171.  
  1172. //</FILE>
  1173.  
  1174. //<FILE="crtframe.c">
  1175. char crtframe_mat[]="┌─┐│┘─└│╔═╗║╝═╚║▐▀▌▌▌▄▐▐████████";
  1176.     //these characters are used to build frames with crtframe
  1177. extern void printc(int c, int x, int y, int color);
  1178.  
  1179. void crtframe (int xi, int yi, int xf, int yf, int color, unsigned int type)
  1180.  //creates a text frame from (xi,yi) to (xf,yf) with color and type, where
  1181.  //(xi,yi) is the upper left corner and (xf,yf) is the lower right corner.
  1182.  {
  1183.     int x,y,a0,a1;
  1184.     if (type>=0x100) //selects character obtained by (type%256) as
  1185.      {                      //frame character
  1186.         a0=type%0x100;
  1187.         for (a1=24;a1<32;a1++)
  1188.             crtframe_mat[a1]=a0;
  1189.         type=3;
  1190.      }
  1191.     if (type>3)    //if (type>3) and (type<100h) return => these values are
  1192.         return;  //reserved for future versions
  1193.                     //if type==3 crtframe draws a frame with the last frame
  1194.                     //character selected when (type>=100h) (default='█')
  1195.     //draws horizontal borders
  1196.     type*=8;
  1197.     a0=crtframe_mat[type+1];
  1198.     a1=crtframe_mat[type+5];
  1199.     for (x=xi+1;x<xf;x++)
  1200.      {
  1201.         printc (a0,x,yi,color);
  1202.         printc (a1,x,yf,color);
  1203.      }
  1204.     //draws vertical borders
  1205.     a0=crtframe_mat[type+3];
  1206.     a1=crtframe_mat[type+7];
  1207.     for (y=yi+1;y<yf;y++)
  1208.      {
  1209.         printc (a1,xi,y,color);
  1210.         printc (a0,xf,y,color);
  1211.      }
  1212.      //draws the corners
  1213.     printc (crtframe_mat[type  ],xi,yi,color);
  1214.     printc (crtframe_mat[type+2],xf,yi,color);
  1215.     printc (crtframe_mat[type+6],xi,yf,color);
  1216.     printc (crtframe_mat[type+4],xf,yf,color);
  1217.  }
  1218. //</FILE>
  1219.  
  1220. //<FILE="crtframw.c">
  1221. extern void crtframe (int xi, int yi, int xf, int yf, int color, unsigned int type);
  1222.  
  1223. #include "crtwin.h"
  1224.  
  1225. void crtframew(int color, unsigned int type)
  1226.  {
  1227.     crtframe(xi,yi,xf,yf,color,type);
  1228.  }
  1229.  
  1230. //</FILE>
  1231.  
  1232. //<FILE="mkline.c">
  1233. extern int getcrtchar (int x, int y);
  1234. extern void printc (int c, int x, int y, int color);
  1235.  
  1236. char const mkline_mat[]="\
  1237. \xff\xff\xff─\xff\xff\xff═\
  1238. \xff┌┐┬\xff╒╕╤\
  1239. \xff└┘┴\xff╘╛╧\
  1240. │├┤┼│╞╡╪\
  1241. \xff\xff\xff─\xff\xff\xff═\
  1242. \xff╓╖╥\xff╔╗╦\
  1243. \xff╙╜╨\xff╚╝╩\
  1244. ║╟╢╫║╠╣╬\
  1245. ";
  1246. //these characters are used in automatic frame lines intersection replacement
  1247. //algorithm by mkline_aux and mkline.
  1248.  
  1249. void mkline_aux (int cnt, int var, unsigned int mode, int pos, int color)
  1250.     //auxiliary function for mkline.
  1251.  {
  1252.     unsigned int c0;
  1253.     unsigned int x,y;
  1254.     char mult;
  1255.     unsigned char c;
  1256.     if ((mode&0x01)==0)
  1257.      {
  1258.         x=var;
  1259.         y=cnt;
  1260.         mult=0x01;
  1261.      }
  1262.      else
  1263.      {
  1264.         x=cnt;
  1265.         y=var;
  1266.         mult=0x08;
  1267.      }
  1268.     c=getcrtchar(x,y);
  1269.     for (c0=0;c0<0x40 && c!=mkline_mat[c0];c0++);
  1270.     if(c0==0x40)
  1271.         c0=0;
  1272.     if (c0==0)
  1273.         pos=3;
  1274.     c0=(c0|(pos*mult));
  1275.     if((mode&0x02)==0)
  1276.         c0=(c0&(-4*mult-1));
  1277.      else
  1278.         c0=(c0|(4*mult));
  1279.     printc(mkline_mat[c0],x,y,color);
  1280.  }
  1281.  
  1282. void mkline (int cnt, int bgn, int end, int color, unsigned int mode)
  1283. //draws lines in menu boxs (text frames) with automatic character replacement
  1284. //when another frame character is found at position where is going to be
  1285. //printed the line.
  1286.  {
  1287.     unsigned c0;
  1288.     mkline_aux(cnt,bgn,mode,1,color);
  1289.     bgn++;
  1290.     for (c0=bgn;c0<end;c0++)
  1291.         mkline_aux(cnt,c0,mode,3,color);
  1292.     mkline_aux(cnt,end,mode,2,color);
  1293.  }
  1294. //</FILE>
  1295.  
  1296. //<FILE="crtwin.c">
  1297. #include <_null.h>
  1298.  
  1299. #include "crtwin.h"
  1300.  
  1301. struct crtwin_inp
  1302.  {
  1303.     char *title; //Title (if title==NULL doesn't print title)
  1304.     int tcolor; //Title color
  1305.     int fchr;   //character used to fill window internal area
  1306.     int fcolor; //internal window area color
  1307.     int bcolor; //border color
  1308.     int btype;  //border type, same as crtframe
  1309.  };
  1310.  
  1311. extern unsigned int strlen(const char *__s);
  1312. extern void     crtframew(int color, unsigned int type);
  1313. extern void     fillbarw (int c, int color);
  1314. extern void        printc    (int c, int x, int y, int color);
  1315. extern void        prints    (char *s, int x, int y, int color);
  1316. extern void        mkline_aux (int cnt, int var, unsigned int mode, int pos, int color);
  1317.  
  1318. void crtwindow (struct crtwin_inp p0)
  1319.  {
  1320.     unsigned int a0,a2,a3;
  1321.  
  1322.     crtframew(p0.bcolor,p0.btype);
  1323.     fillbarw(p0.fchr,p0.fcolor);
  1324.     if (p0.title!=NULL)
  1325.      {
  1326.         a0=strlen(p0.title);
  1327.         a2=(xi+xf-a0)/2;
  1328.         a3=(xi+xf+a0)/2+1;
  1329.         printc(' ',a2,yi,p0.tcolor);
  1330.         printc(' ',a3,yi,p0.tcolor);
  1331.         if ((unsigned)p0.btype <2)
  1332.          {
  1333.             mkline_aux(a2,yi,1,3,p0.bcolor);
  1334.             mkline_aux(a3,yi,1,3,p0.bcolor);
  1335.             mkline_aux(yi,a2,2*p0.btype,2,p0.bcolor);
  1336.             mkline_aux(yi,a3,2*p0.btype,1,p0.bcolor);
  1337.          }
  1338.         prints(p0.title,a2+1,yi,p0.tcolor);
  1339.      }
  1340.  }
  1341. //</FILE>
  1342.  
  1343. //<FILE="savvideo.c">
  1344. extern int vmode_x;
  1345. extern int vmode_y;
  1346. extern int crt_direct;
  1347. extern char far *video_addr;
  1348.  
  1349. extern int getcrtchar (int x, int y);
  1350. extern int getcrtcolor (int x,int y);
  1351.  
  1352. char far *savevideo (char far *s) //saves video contents into "s" buffer
  1353.  {
  1354.     int c0,c1,a0;
  1355.     char far *crtvar_p; //used to access the video RAM
  1356.  
  1357.     if (!crt_direct)
  1358.      {
  1359.         a0=vmode_x*vmode_y;
  1360.         crtvar_p=video_addr; //points to video RAM
  1361.         for (c0=0;c0<a0;c0++)
  1362.          {
  1363.             *s=*crtvar_p;
  1364.             *(s+1)=*(crtvar_p+1);
  1365.             crtvar_p+=2; s+=2;
  1366.          }
  1367.      }
  1368.      else
  1369.         for (c0=0;c0<vmode_y;c0++)
  1370.             for (c1=0;c1<vmode_x;c1++)
  1371.              {
  1372.                 *s=getcrtchar(c1,c0); s++;
  1373.                 *s=getcrtcolor(c1,c0); s++;
  1374.              }
  1375.     return s;
  1376.  }
  1377. //</FILE>
  1378.  
  1379. //<FILE="rstvideo.c">
  1380. extern int vmode_x;
  1381. extern int vmode_y;
  1382. extern int crt_direct;
  1383. extern char far *video_addr;
  1384.  
  1385. extern void biosprintc (int chr, int x, int y, int color, int func);
  1386.  
  1387. char far *restorevideo (char far *s) //sends "s" buffer contents to screen
  1388.  {
  1389.     int c0,c1,a0,chr;
  1390.     char far *crtvar_p; //used to access the video RAM
  1391.  
  1392.     if (!crt_direct)
  1393.      {
  1394.         a0=vmode_x*vmode_y;
  1395.         crtvar_p=video_addr;        //points to video RAM
  1396.         for (c0=0;c0<a0;c0++)
  1397.          {
  1398.             *crtvar_p=*s;
  1399.             *(crtvar_p+1)=*(s+1);
  1400.             crtvar_p+=2; s+=2;
  1401.          }
  1402.      }
  1403.      else
  1404.         for (c0=0;c0<vmode_y;c0++)
  1405.             for (c1=0;c1<vmode_x;c1++)
  1406.              {
  1407.                 chr=*s; s++;
  1408.                 biosprintc(chr,c1,c0,*s,0x09);
  1409.                 s++;
  1410.              }
  1411.     return s;
  1412.  }
  1413. //</FILE>
  1414.  
  1415. //<FILE="savevidw.c">
  1416. extern int getcrtchar (int x, int y);
  1417. extern int getcrtcolor (int x,int y);
  1418.  
  1419. char far *savevideowin(char far *s, int xi, int yi, int xf, int yf)
  1420. //saves a text window into "s" buffer.
  1421.  {
  1422.     int c0,c1;
  1423.     yf++; xf++;
  1424.     for (c0=yi;c0<yf;c0++)
  1425.         for (c1=xi;c1<xf;c1++)
  1426.          {
  1427.             *s=getcrtchar(c1,c0); s++;
  1428.             *s=getcrtcolor(c1,c0); s++;
  1429.          }
  1430.     return s;
  1431.  }
  1432. //</FILE>
  1433.  
  1434. //<FILE="rstvidw.c">
  1435. extern void printc (int c, int x, int y, int color);
  1436.  
  1437. char far *restorevideowin(char far *s, int xi, int yi, int xf, int yf)
  1438. //sends "s" buffer contents to a text window.
  1439.  {
  1440.     int c0,c1,a0;
  1441.     yf++; xf++;
  1442.     for (c0=yi;c0<yf;c0++)
  1443.         for (c1=xi;c1<xf;c1++)
  1444.          {
  1445.             a0=*s;
  1446.             s++;
  1447.             printc(a0,c1,c0,*s);
  1448.             s++;
  1449.          }
  1450.     return s;
  1451.  }
  1452. //</FILE>
  1453.  
  1454. //<FILE="savvidw2.c">
  1455. extern char far *savevideowin(char far *s, int xi, int yi, int xf, int yf);
  1456.  
  1457. #include "crtwin.h"
  1458.  
  1459. char far *savevideow(char far *s)
  1460.  {
  1461.     return (char far*) savevideowin(s,xi,yi,xf,yf);
  1462.  }
  1463.  
  1464. //</FILE>
  1465.  
  1466. //<FILE="rstvidw2.c">
  1467. extern char far *restorevideowin(char far *s, int xi, int yi, int xf, int yf);
  1468.  
  1469. #include "crtwin.h"
  1470.  
  1471. char far *restorevideow(char far *s)
  1472.  {
  1473.     return (char far*) restorevideowin(s,xi,yi,xf,yf);
  1474.  }
  1475.  
  1476. //</FILE>
  1477.  
  1478. //<FILE="savecrt.c">
  1479. extern int vmode_x;
  1480. extern int vmode_y;
  1481. extern int crt_direct;
  1482. extern char far *video_addr;
  1483.  
  1484. extern int getcrtchar (int x, int y);
  1485. extern int getcrtcolor (int x,int y);
  1486.  
  1487. #include <_NULL.H>
  1488.  
  1489. char far *savecrt (char far *s, int mode)
  1490. //saves screen contents into "s" buffer with mode
  1491.  {
  1492.     int c0,c1,a0;
  1493.     char far *crtvar_p; //used to access the video RAM
  1494.  
  1495.     if ((unsigned)mode>=4)
  1496.         return NULL;
  1497.  
  1498.     if (!crt_direct)
  1499.      {
  1500.         a0=vmode_x*vmode_y;
  1501.         crtvar_p=video_addr; //points to video RAM
  1502.         if (mode==0)
  1503.          {
  1504.             for (c0=0;c0<a0;c0++)
  1505.              {
  1506.                 *s=*crtvar_p;
  1507.                 *(s+1)=*(crtvar_p+1);
  1508.                 crtvar_p+=2; s+=2;
  1509.              }
  1510.          }
  1511.          else if (mode==1)
  1512.          {
  1513.             for (c0=0;c0<a0;c0++)
  1514.              {
  1515.                 *s=*(crtvar_p+1); s++;
  1516.                 *s=*crtvar_p; s++;
  1517.                 crtvar_p+=2;
  1518.              }
  1519.          }
  1520.          else
  1521.          {
  1522.             if (mode==3)
  1523.                 crtvar_p++;
  1524.             for (c0=0;c0<a0;c0++)
  1525.              {
  1526.                 *s=*crtvar_p;
  1527.                 crtvar_p+=2; s++;
  1528.              }
  1529.          }
  1530.      }
  1531.      else
  1532.       {
  1533.         for (c0=0;c0<vmode_y;c0++)
  1534.             for (c1=0;c1<vmode_x;c1++)
  1535.              {
  1536.                 if (mode==1)
  1537.                  {
  1538.                     *s=getcrtcolor(c1,c0); s++;
  1539.                     *s=getcrtchar (c1,c0); s++;
  1540.                  }
  1541.                 else
  1542.                  {
  1543.                     if (mode!=3)
  1544.                      {
  1545.                         *s=getcrtchar(c1,c0);
  1546.                         s++;
  1547.                      }
  1548.                     if (mode!=2)
  1549.                      {
  1550.                         *s=getcrtcolor(c1,c0);
  1551.                         s++;
  1552.                      }
  1553.                  }
  1554.              }
  1555.       }
  1556.     return s;
  1557.  }
  1558. //</FILE>
  1559.  
  1560. //<FILE="rstcrt.c">
  1561. extern int vmode_x;
  1562. extern int vmode_y;
  1563. extern int crt_direct;
  1564. extern char far *video_addr;
  1565.  
  1566. extern void printc (int chr, int x, int y, int color);
  1567. extern void printcn (int c,int x, int y);
  1568. extern void changecolor (int x, int y, int color);
  1569.  
  1570. #include <_NULL.H>
  1571.  
  1572. char far *restorecrt (char far *s, int mode)
  1573. //sends "s" buffer contents to screen with mode
  1574.  {
  1575.     int c0,c1,a0,chr,color;
  1576.     char far *crtvar_p;//used to access the video RAM
  1577.  
  1578.     if ((unsigned)mode>=4)
  1579.         return NULL;
  1580.  
  1581.     if (!crt_direct)
  1582.      {
  1583.         a0=vmode_x*vmode_y;
  1584.         crtvar_p=video_addr; //points to video RAM
  1585.         if (mode==0)
  1586.          {
  1587.             for (c0=0;c0<a0;c0++)
  1588.              {
  1589.                 *crtvar_p=*s;
  1590.                 *(crtvar_p+1)=*(s+1);
  1591.                 crtvar_p+=2; s+=2;
  1592.              }
  1593.          }
  1594.          else if (mode==1)
  1595.          {
  1596.             for (c0=0;c0<a0;c0++)
  1597.              {
  1598.                 *(crtvar_p+1)=*s; s++;
  1599.                 *crtvar_p=*s; s++;
  1600.                 crtvar_p+=2;
  1601.              }
  1602.          }
  1603.          else
  1604.          {
  1605.             if (mode==3)
  1606.                 crtvar_p++;
  1607.             for (c0=0;c0<a0;c0++)
  1608.              {
  1609.                 *crtvar_p=*s;
  1610.                 crtvar_p+=2; s++;
  1611.              }
  1612.          }
  1613.      }
  1614.      else
  1615.       {
  1616.         for (c0=0;c0<vmode_y;c0++)
  1617.             for (c1=0;c1<vmode_x;c1++)
  1618.              {
  1619.                 if (mode<2)
  1620.                  {
  1621.                     if (mode==0)
  1622.                      {
  1623.                         chr=*s; s++;
  1624.                         color=*s; s++;
  1625.                      }
  1626.                      else
  1627.                      {
  1628.                         color=*s; s++;
  1629.                         chr=*s; s++;
  1630.                      }
  1631.                     printc(chr,c1,c0,color);
  1632.                  }
  1633.                 else
  1634.                  {
  1635.                     if (mode==2)
  1636.                      {
  1637.                         printcn(*s,c1,c0);
  1638.                         s++;
  1639.                      }
  1640.                     if (mode==3)
  1641.                      {
  1642.                         changecolor(c1,c0,*s);
  1643.                         s++;
  1644.                      }
  1645.                  }
  1646.              }
  1647.       }
  1648.     return s;
  1649.  }
  1650. //</FILE>
  1651.  
  1652. //<FILE="savecrtw.c">
  1653. extern int getcrtchar (int x, int y);
  1654. extern int getcrtcolor (int x,int y);
  1655.  
  1656. #include <_NULL.H>
  1657.  
  1658. char far *savecrtwin (char far *s, int xi, int yi, int xf, int yf, int mode)
  1659. //saves a text window into "s" buffer with mode.
  1660.  {
  1661.     int c0,c1;
  1662.  
  1663.     if ((unsigned)mode>=4)
  1664.         return NULL;
  1665.  
  1666.     yf++; xf++;
  1667.     for (c0=yi;c0<yf;c0++)
  1668.         for (c1=xi;c1<xf;c1++)
  1669.          {
  1670.             if (mode==1)
  1671.              {
  1672.                 *s=getcrtcolor(c1,c0); s++;
  1673.                 *s=getcrtchar (c1,c0); s++;
  1674.              }
  1675.             else
  1676.              {
  1677.                 if (mode!=3)
  1678.                  {
  1679.                     *s=getcrtchar(c1,c0);
  1680.                     s++;
  1681.                  }
  1682.                 if (mode!=2)
  1683.                  {
  1684.                     *s=getcrtcolor(c1,c0);
  1685.                     s++;
  1686.                  }
  1687.              }
  1688.          }
  1689.     return s;
  1690.  }
  1691. //</FILE>
  1692.  
  1693. //<FILE="rstcrtw.c">
  1694. extern void printc (int c, int x, int y, int color);
  1695. extern void printcn (int c,int x, int y);
  1696. extern void changecolor (int x, int y, int color);
  1697.  
  1698. #include <_NULL.H>
  1699.  
  1700. char far *restorecrtwin (char far *s, int xi, int yi, int xf, int yf, int mode)
  1701. //sends "s" buffer contents to a text window with mode.
  1702.  {
  1703.     int c0,c1,chr,color;
  1704.  
  1705.     if ((unsigned)mode>=4)
  1706.         return NULL;
  1707.  
  1708.     xf++; yf++;
  1709.     for (c0=yi;c0<yf;c0++)
  1710.         for (c1=xi;c1<xf;c1++)
  1711.          {
  1712.             if (mode<2)
  1713.              {
  1714.                 if (mode==0)
  1715.                  {
  1716.                     chr=*s; s++;
  1717.                     color=*s; s++;
  1718.                  }
  1719.                  else
  1720.                  {
  1721.                     color=*s; s++;
  1722.                     chr=*s; s++;
  1723.                  }
  1724.                 printc(chr,c1,c0,color);
  1725.              }
  1726.             else
  1727.              {
  1728.                 if (mode==2)
  1729.                  {
  1730.                     printcn(*s,c1,c0);
  1731.                     s++;
  1732.                  }
  1733.                 if (mode==3)
  1734.                  {
  1735.                     changecolor(c1,c0,*s);
  1736.                     s++;
  1737.                  }
  1738.              }
  1739.          }
  1740.     return s;
  1741.  }
  1742. //</FILE>
  1743.  
  1744. //<FILE="savcrtw2.c">
  1745. extern char far *savecrtwin (char far *s, int xi, int yi, int xf, int yf, int mode);
  1746.  
  1747. #include "crtwin.h"
  1748.  
  1749. char far *savecrtw(char far *s, int mode)
  1750.  {
  1751.     return (char far*) savecrtwin(s,xi,yi,xf,yf,mode);
  1752.  }
  1753.  
  1754. //</FILE>
  1755.  
  1756. //<FILE="rstcrtw2.c">
  1757. extern char far *restorecrtwin (char far *s, int xi, int yi, int xf, int yf, int mode);
  1758.  
  1759. #include "crtwin.h"
  1760.  
  1761. char far *restorecrtw(char far *s, int mode)
  1762.  {
  1763.     return (char far *) restorecrtwin(s,xi,yi,xf,yf,mode);
  1764.  }
  1765. //</FILE>
  1766.  
  1767. //<FILE="cursorsh.c">
  1768. #define intm(intnum) asm int intnum
  1769.  
  1770. extern int crt_page;
  1771. extern int vmode_mode;
  1772.  
  1773. //These functions works at text page defined by crt_page (default=0)
  1774. void setcursorsh (unsigned int shape) //changes the cursor shape.
  1775.     //bit 15-> must be 0; bits 14,13 -> cursor blink (invisible, blinking)
  1776.     //bits 12-8 -> upper scan line        bits 4-0 -> lower scan line
  1777.     //Data from Ralf Brown Files
  1778.  {
  1779.     asm push ax;
  1780.     asm push cx;
  1781.     asm push dx;
  1782.     _DH=0x01;
  1783.     _DL=vmode_mode;
  1784.     _CX=shape;
  1785.     asm mov ax,dx;
  1786.     intm(0x10);
  1787.     asm pop dx;
  1788.     asm pop cx;
  1789.     asm pop ax;
  1790.  }
  1791.  
  1792. int getcursorsh (void) //gets the current cursor shape.
  1793.  {
  1794.     unsigned int rtn;
  1795.     asm push ax;
  1796.     asm push bx;
  1797.     asm push cx;
  1798.     asm push dx;
  1799.     _BH=crt_page;
  1800.     _AH=0x03;
  1801.     intm(0x10);
  1802.     rtn=_CX;
  1803.     asm pop dx;
  1804.     asm pop cx;
  1805.     asm pop bx;
  1806.     asm pop ax;
  1807.     return rtn;
  1808.  }
  1809. //</FILE>
  1810.  
  1811. //<FILE="crtpal.c">
  1812. #define intm(intnum) asm int intnum
  1813.  
  1814. int getpalreg (int regpal) //returns the palette register (regpal) value
  1815. //(DAC register number)
  1816. //Compatibility: EGA(with UltraVision v2+), VGA, UltraVision v2+, and above
  1817.  
  1818.  {
  1819.     int a0;
  1820.     asm push ax;
  1821.     asm push bx;
  1822.     _BL=regpal;
  1823.     _BH=0xFF;
  1824.     _AX=0x1007;
  1825.     intm (0x10);
  1826.     a0=_BH;
  1827.     asm pop bx;
  1828.     asm pop ax;
  1829.     return a0; //returns selected DAC register index
  1830.  }
  1831.  
  1832. void setpalreg (int regpal, int val) //selects DAC register for specified
  1833. //color (palette register)
  1834. //Compatibility: PCjr,Tandy,EGA,MCGA,VGA and above
  1835.  {
  1836.     asm push ax;
  1837.     asm push bx;
  1838.     _BH=val;
  1839.     _BL=regpal;
  1840.     _AX=0x1000;
  1841.     intm (0x10);
  1842.     asm pop bx;
  1843.     asm pop ax;
  1844.  }
  1845.  
  1846. //</FILE>
  1847.  
  1848. //<FILE="crtbord.c">
  1849. #define intm(intnum) asm int intnum
  1850.  
  1851. int getbordercolor (void) //returns the DAC register index for overscan color
  1852. //(screen border color)
  1853.  {
  1854.     int a0;
  1855.     asm push ax;
  1856.     asm push bx;
  1857.     _BH=0xFF;
  1858.     _AX=0x1008;
  1859.     intm (0x10);
  1860.     a0=_BH;
  1861.     asm pop bx;
  1862.     asm pop ax;
  1863.     return a0;
  1864.  }
  1865.  
  1866. void setbordercolor (int val) //set's screen border color (overscan color)
  1867.  {
  1868.     asm push ax;
  1869.     asm push bx;
  1870.     _BH=val;
  1871.     _AX=0x1001;
  1872.     intm (0x10);
  1873.     asm pop bx;
  1874.     asm pop ax;
  1875.  }
  1876.  
  1877. //</FILE>
  1878.  
  1879. //<FILE="crtdacr.c">
  1880. void getdacreg (int dacreg, char *red, char *green, char *blue)
  1881. //gets the color from individual DAC register
  1882.  {
  1883.     asm push ax;
  1884.     asm push bx;
  1885.     asm push cx;
  1886.     asm push dx;
  1887.     _BL=dacreg;
  1888.     _AX=0x1015;
  1889.     asm int 0x10;
  1890.     *red=_DH;
  1891.     *green=_CH;
  1892.     *blue=_CL;
  1893.     asm pop dx;
  1894.     asm pop cx;
  1895.     asm pop bx;
  1896.     asm pop ax;
  1897.  }
  1898.  
  1899. void setdacreg (int dacreg, char red, char green, char blue)
  1900. //changes the color of a individual DAC register
  1901.  {
  1902.     asm push ax;
  1903.     asm push bx;
  1904.     asm push cx;
  1905.     asm push dx;
  1906.     _BX=dacreg;
  1907.     _CH=green;
  1908.     _CL=blue;
  1909.     _DH=red;
  1910.     _AX=0x1010;
  1911.     asm int 0x10;
  1912.     asm pop dx;
  1913.     asm pop cx;
  1914.     asm pop bx;
  1915.     asm pop ax;
  1916.  }
  1917.  
  1918. void setdacpgmode (int pgmode) //selects video DAC paging mode
  1919. //pgmode== 0 => 4 Blocks of 64
  1920. //pgmode== 1 => 16 Blocks of 16
  1921. //this function is not valid in mode 13h (19)d
  1922.  {
  1923.     asm {
  1924.         push ax;
  1925.         push bx;
  1926.     }
  1927.     _BH=pgmode;
  1928.     asm {
  1929.         xor bl,bl; //_BL=0
  1930.         mov ax,0x1013;
  1931.         int 0x10;
  1932.         pop bx;
  1933.         pop ax;
  1934.     }
  1935.  }
  1936.  
  1937. void setdacpage(int page) //selects video DAC color page
  1938. //page == page number (0-3) or (0-15)
  1939. //this function is not valid in mode 13h (19)d
  1940.  {
  1941.     asm {
  1942.         push ax;
  1943.         push bx;
  1944.     }
  1945.     _BH=page;
  1946.     asm {
  1947.         mov bl,1;
  1948.         mov ax,0x1013;
  1949.         int 0x10;
  1950.         pop bx;
  1951.         pop ax;
  1952.     }
  1953.  }
  1954.  
  1955. int getdacpgstate (void) //returns a word containing video DAC information
  1956. //bits 15-8 => current DAC page
  1957. //bits 7-0  => paging mode (0 => 4 pages of 64)  (1 => 16 pages of 16)
  1958.  {
  1959.     asm {
  1960.         push bx;
  1961.         mov ax,0x101A;
  1962.         int 0x10;
  1963.      }
  1964.     asm mov ax,bx;
  1965.     asm pop bx;
  1966.     return _AX;
  1967.  }
  1968. //</FILE>
  1969.  
  1970. //<FILE="boxwidth.c">
  1971. unsigned char  __inportb__( int __portid );
  1972. unsigned int   __inportw__( int __portid );
  1973. void           __outportb__( int __portid, unsigned char __value );
  1974. void           __outportw__( int __portid, unsigned int __value );
  1975.  
  1976. #define inportb         __inportb__
  1977. #define outportb        __outportb__
  1978.  
  1979. extern int crt_EVGA_addr; //EGA/VGA base port address.
  1980.  
  1981. void setchrboxwidth (int cmd)
  1982. //cmd == 0 => set's 9 pixels character box width
  1983. //cmd == 1 => set's 8 pixels character box width
  1984. //cmd == 2 => if 9 pixel box width is selected, selects 8 pixels, and vice versa.
  1985.  {
  1986.     register unsigned char a0,a1;
  1987.     outportb(crt_EVGA_addr+4u,1u); //selects clocking mode register
  1988.     a0=inportb(crt_EVGA_addr+5u); //a0 <= VGA sequencer clocking mode register
  1989.     if (cmd==2)
  1990.         a0^=0x01; //XORS bit 0 of a0
  1991.     else if (cmd==1)
  1992.         a0|=0x01; //SETS bit 0 of a0
  1993.     else if (cmd==0)
  1994.         a0&=0xfe; //CLEARS bit 0 of a0
  1995.     outportb(crt_EVGA_addr+5u,a0);//VGA sequencer clocking mode register is loaded with a0
  1996.  
  1997.     a1=inportb(crt_EVGA_addr+0x0Cu);//a1 <= VGA miscellaneous output register
  1998.     a1&=0xf3; //clears bit 3 and 2.
  1999.     if (!(a0&0x01)) //if bit 0 of a1 is cleared (cmd==0)
  2000.         a1|=0x04;    //sets bit 2 of a1, selecting the pixelclock frequency
  2001.                         //for a character box 9 pixels wide.
  2002.                         //otherwise (bit 2 reseted), selected frequency is for a
  2003.                         //character box 8 pixels wide.
  2004.     outportb(crt_EVGA_addr+2u,a1); //VGA miscellaneous output register <= a1
  2005.  }
  2006. //</FILE>
  2007.  
  2008. //<FILE="textblnk.c">
  2009. #define intm(intnum) asm int intnum
  2010.  
  2011. void settextblink (int cmd) //if cmd==1 => set attribute bit 7 as enable blink
  2012. //bit (default), otherwise it becomes background intensity bit
  2013.  {
  2014.     cmd%=(unsigned)256u;
  2015.     if ((unsigned)cmd>1)
  2016.         return;
  2017.     asm push ax;
  2018.     asm push bx;
  2019.     _BX=cmd;
  2020.     _AX=0x1003;
  2021.     intm (0x10);
  2022.     asm pop bx;
  2023.     asm pop ax;
  2024.  }
  2025. //</FILE>
  2026.  
  2027. //<FILE="changchr.c">
  2028. #define intm(intnum) asm int intnum
  2029. #define FP_SEG( fp )( (unsigned )( void _seg * )( void far * )( fp ))
  2030. #define FP_OFF( fp )( (unsigned )( fp ))
  2031.  
  2032. int changechar_height=16;
  2033. int changechar_func=0x1100;
  2034. int changechar_blk=0;
  2035.  
  2036. void changechar (unsigned char *fmt, int ind, int qt)
  2037.  {
  2038.     if(changechar_func!=0x1100 && changechar_func!=0x1110)//protection against
  2039.         return; //wrong changechar_func values
  2040.     asm push ax;
  2041.     asm push bx;
  2042.     asm push cx;
  2043.     asm push dx;
  2044.     asm push es;
  2045.     _BH=changechar_height;
  2046.     _BL=changechar_blk;
  2047.     _CX=qt;
  2048.     _DX=ind;
  2049.     _AX=changechar_func;
  2050.     asm push bp
  2051.     asm push ax
  2052.     _ES=FP_SEG(fmt);
  2053.     _BP=FP_OFF(fmt);
  2054.     asm pop ax;
  2055.     intm(0x10);
  2056.     asm pop bp;
  2057.     asm pop es;
  2058.     asm pop dx;
  2059.     asm pop cx;
  2060.     asm pop bx;
  2061.     asm pop ax;
  2062.  }
  2063.  
  2064. void changecharg (unsigned char *fmt, int rows)
  2065.  {
  2066.     asm push ax;
  2067.     asm push bx;
  2068.     asm push cx;
  2069.     asm push dx;
  2070.     asm push es;
  2071.     _BL=0x00;
  2072.     _CX=changechar_height;
  2073.     _DL=rows;
  2074.     asm push bp
  2075.     _ES=FP_SEG(fmt);
  2076.     _BP=FP_OFF(fmt);
  2077.     _AX=0x1121;
  2078.     intm(0x10);
  2079.     asm pop bp;
  2080.     asm pop es;
  2081.     asm pop dx;
  2082.     asm pop cx;
  2083.     asm pop bx;
  2084.     asm pop ax;
  2085.  }
  2086. //</FILE>
  2087.  
  2088. //<FILE="videolib.dat">
  2089. + crtvar   + crtdtect + crt_init + vmode    + crtmode  &
  2090. + crtpage  + crt_gtxy + getxy    + getcrtch + getcrtco &
  2091. + b_printc + printcn  + printc   + changeco + printct  &
  2092. + printsn  + prints   + printxy  + printx   + printt   &
  2093. + printsj  + printsjc + printsnf + printsf  + printxyf &
  2094. + printxf  + printtf  + printsjf + prntsjcf + fillscr  &
  2095. + barcolor + fillbar  + fillbarw + fillbox  + fillboxw &
  2096. + crtframe + crtframw + mkline   + crtwin   + savvideo &
  2097. + rstvideo + savevidw + rstvidw  + savvidw2 + rstvidw2 &
  2098. + savecrt  + rstcrt   + savecrtw + rstcrtw  + savcrtw2 &
  2099. + rstcrtw2 + cursorsh + crtpal   + crtbord  + crtdacr  &
  2100. + boxwidth + textblnk + changchr
  2101. //</FILE>
  2102.  
  2103. //<FILE="compile.bat">
  2104. tcc -c -m%1 %2 %3 %4 %5 %6 %7 %8 %9 *.c
  2105. tlib video%1 @videolib.dat
  2106. del *.obj
  2107. //</FILE>
  2108.  
  2109. //<FILE="asmlibs.bat">
  2110. call compile s %1 %2 %3 %4 %5 %6 %7 %8 %9
  2111. call compile m %1 %2 %3 %4 %5 %6 %7 %8 %9
  2112. call compile c %1 %2 %3 %4 %5 %6 %7 %8 %9
  2113. call compile l %1 %2 %3 %4 %5 %6 %7 %8 %9
  2114. call compile h %1 %2 %3 %4 %5 %6 %7 %8 %9
  2115. @echo  
  2116. @echo If you wish to create libraries for 186 or 286 Protected Mode Instructions
  2117. @echo use the lines below
  2118. @echo tcc -c -1 [options] *.c
  2119. @echo tlib video186 @videolib.dat
  2120. @echo tcc -c -2 [options] *.c
  2121. @echo tlib video286 @videolib.dat
  2122. //</FILE>
  2123.